home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / db / esm-3.1 / esm-3 / usr / local / sm / src / serverlib / distr / replyWithAck.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-05  |  3.6 KB  |  148 lines

  1. /*
  2.  *   $RCSfile: replyWithAck.c,v $  
  3.  *   $Revision: 1.1.1.1 $  
  4.  *   $Date: 1996/05/04 21:55:40 $      
  5.  */ 
  6. /**********************************************************************
  7. * EXODUS Database Toolkit Software
  8. * Copyright (c) 1991 Computer Sciences Department, University of
  9. *                    Wisconsin -- Madison
  10. * All Rights Reserved.
  11. *
  12. * Permission to use, copy, modify and distribute this software and its
  13. * documentation is hereby granted, provided that both the copyright
  14. * notice and this permission notice appear in all copies of the
  15. * software, derivative works or modified versions, and any portions
  16. * thereof, and that both notices appear in supporting documentation.
  17. *
  18. * THE COMPUTER SCIENCES DEPARTMENT OF THE UNIVERSITY OF WISCONSIN --
  19. * MADISON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION.  
  20. * THE DEPARTMENT DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES
  21. * WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
  22. *
  23. * The EXODUS Project Group requests users of this software to return 
  24. * any improvements or extensions that they make to:
  25. *
  26. *   EXODUS Project Group 
  27. *     c/o David J. DeWitt and Michael J. Carey
  28. *   Computer Sciences Department
  29. *   University of Wisconsin -- Madison
  30. *   Madison, WI 53706
  31. *
  32. *     or exodus@cs.wisc.edu
  33. *
  34. * In addition, the EXODUS Project Group requests that users grant the 
  35. * Computer Sciences Department rights to redistribute these changes.
  36. **********************************************************************/
  37.  
  38. #include "sysdefs.h"
  39. #include "ess.h"
  40. #include "checking.h"
  41. #include "trace.h"
  42. #include "error.h"
  43. #include "list.h"
  44. #include "pool.h"
  45. #include "tid.h"
  46. #include "io.h"
  47. #include "lock.h"
  48. #include "object.h"
  49. #include "msgdefs.h"
  50. #include "thread.h"
  51. #include "semaphore.h"
  52. #include "link.h"
  53. #include "lsn.h"
  54. #include "latch.h"
  55. #include "bf.h"
  56. #include "volume.h"
  57. #include "trans.h"
  58. #include "bitvec.h"
  59. #include "trans_intfuncs.h"
  60. #include "trans_extfuncs.h"
  61. #include "msg_funcs.h"
  62. #include "cl_funcs.h"
  63. #include "thread_funcs.h"
  64. #include "thread_globals.h"
  65. #include "trans_globals.h"
  66. #include "distr.h"
  67. #include "server_util_funcs.h"
  68. #include "distr_intfuncs.h"
  69. #include "distr_globals.h"
  70. #include "admin_funcs.h"
  71.  
  72.  
  73.  void
  74. replyWithAck (
  75.  
  76.     register TRANSREC    *transRec
  77. )
  78. {
  79.  
  80.     TID                localTid = Active->message.body.vote.localTid;
  81.     TID                coordTid = Active->message.body.vote.coordTid;
  82.  
  83.  
  84.     TRPRINT(TR_TRANS, TR_LEVEL_1, ("localTid:%x", localTid));
  85.  
  86.     /*
  87.      *    initialize the type, coordTid, and localTid of the reply message
  88.      */
  89.     Active->message.header.type = SERVER_ACK;
  90.     Active->message.body.ack.coordTid = coordTid;
  91.     Active->message.body.ack.localTid = localTid;
  92.  
  93.     /*
  94.      *    mark the active transaction
  95.      */
  96.     Active->transRec = (char *) transRec;
  97.  
  98.     SM_ASSERT(LEVEL_3, (transRec->transState == T_PREPARED));
  99.     SM_ASSERT(LEVEL_3, ((transRec->coordCommand == C_COMMIT) || 
  100.                         (transRec->coordCommand == C_ABORT)));
  101.  
  102.     /*
  103.      * carry out the command
  104.      */
  105.     if (transRec->coordCommand == C_COMMIT) {
  106.  
  107.         /*
  108.          *  mark the intent to commit
  109.          */
  110.         transRec->intent = T_COMMIT;
  111.  
  112.         /*
  113.          *    commit the transaction
  114.          */
  115.         if (serverCommitTrans(transRec)) {
  116.  
  117.                  /* TODO: operator recovery required */
  118.                  SM_ERROR(TYPE_CRASH, esmINTERNAL);
  119.  
  120.          } else {
  121.  
  122. #ifdef DEBUG
  123.     if (DebugCrashLoc == 15)
  124.         admin_ShutServer(0);
  125. #endif DEBUG
  126.               replyDatagram(esmNOERROR, esmNOERROR, 1, TRUE);
  127.          }
  128.  
  129.     } else if (transRec->coordCommand == C_ABORT) {
  130.  
  131.         /*
  132.          *  mark the intent to abort
  133.          */
  134.         transRec->intent = T_ABORT;
  135.  
  136.         /*
  137.          *    abort the transaction
  138.          */
  139.         abortTrans(transRec, esmCLIENTREQUEST);
  140.  
  141.         /*
  142.          *    restart this thread
  143.          */
  144.         transThreadDeath(Active); 
  145.         threadRestart();
  146.     }
  147. }
  148.